﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication35
{
    class Car
    {
        private int position;

        private Timer timer;

        public Car() {

            timer  = new Timer(DrawCar, null, Timeout.Infinite, Timeout.Infinite);
        }

       public void Go()
       {
            timer.Change(0, 100);
       }

        public void GoSlowly()
        {
            timer.Change(0, 500);
        }

        public void Stop()
        {
            timer.Change(Timeout.Infinite, Timeout.Infinite);
        }

        private void DrawCar (object obj)
        {
            string s = new string(' ', position) + "m";
            Console.Clear();
            Console.Write(s);
            position++;
            if (position > 80)
            {
                position = 0;
            }
        }
    }
}
